package com.example.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * Created by lianlei on 2017/1/13.
 */
@WebFilter(filterName="myFilter",urlPatterns="/*")
public class MyFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println ("程序开始~~~~~~");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
       // System.out.println (filterChain.getClass ().getResourceAsStream ("InputStream"));
        servletRequest.setCharacterEncoding ("UTF-8");
        servletResponse.setCharacterEncoding ("UTF-8");
        filterChain.doFilter (servletRequest,servletResponse);
    }

    @Override
    public void destroy() {
        System.out.println ("执行结束！！！");
    }
}
